package com.bsoft.gol.hbs.task;

import ctd.controller.exception.ControllerException;
import ctd.job.annotation.ScheduleJob;
import ctd.job.pojo.JobParameter;
import ctd.util.context.ContextUtils;
import hcn.common.Constants;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.atag.util.common.SpringPropertiesUtil;
import com.bsoft.gol.hbs.service.SynchronizationDeptService;

/**
 * @program: Myproject
 * @description: 同步机构科室
 * @author: zangsf
 * @create: 2022-06-01 14:26
 **/
@Component
public class OrganizationDeptJob {

    private static final Logger logger = LoggerFactory.getLogger(OrganizationDeptJob.class);

    @Autowired
    private SynchronizationDeptService synchronizationDeptService;

    /* *
     * @description :随访科室同步-->每天凌晨执行一次
     * @author      :zangsf
     * @date        :2022-06-01 15:28
     * @param       :[]
     * @return      :void
     */
//    @ScheduleJob(jobName = "syncFusDept", cron = "0 0 0 * * ?", shardingTotalCount = 1, description = "随访科室同步定时器",
  //          overwrite = true)
    public void synchronizationDeptByService(JobParameter jobParameter) throws ControllerException {
        String tenantId = (String) ContextUtils.get("$tenantId");
        if(null == tenantId){
            ContextUtils.put("$tenantId", SpringPropertiesUtil.get("tenantId"));
        }

        logger.info("syncFusDept start");
//        外部接口暂未开发
        synchronizationDeptService.SynchronizationDeptByService();
        logger.info("syncFusDept end");
    }

}
